<template>
  <div>
    <div class="container">
      <div class="flex_center titleBox">
        <div>
          <img class="orgIcon" src="/web-hft-ee/static/img/orgCenter/title_left.png">
        </div>
        <div class="title">企业特权</div>
        <div>
          <img class="orgIcon" src="/web-hft-ee/static/img/orgCenter/title_right.png">
        </div>
      </div>
      <div class="rightView" @click="toLevelUp('intro')">
        <div class="itemView" v-for="item in list" v-if="item.active || type">
          <org-right-item :item=item></org-right-item>
        </div>

      </div>
      <div class="bottomBox" v-if="type">
        <div style="height: 32px;"></div>
        <p>更多特权，敬请期待</p>
<!--        <div class="level" @click="exitOrg">退出企业</div>-->
        <div style="height: 24px;"></div>
      </div>
    </div>
  </div>
</template>

<script>
  import OrgRightItem from "./OrgRightItem";
  import {tryList, goldList, plList, diamondList} from '../orgList'

  export default {
    name: "OrgRight",
    components: {OrgRightItem},
    props: {
      level: {
        type: Number,
        required: true,
      },
      type: {
        type: Boolean,
        default: true,
      },
      isExpire:{
        type: Boolean,
        default: false,
      }
    },
    data() {
      return {
        list: [],
      }
    },
    computed: {},
    watch: {
      level(nval, oval) {
        console.log(nval, oval)
        this.fetchData(this.level)
      },
    },
    mounted() {
      this.fetchData(this.level)
    },
    methods: {
      fetchData(level) {
        if(this.isExpire){
          this.list = tryList;
        }else{
          console.log('level',level);
          switch (Number(level)) {
            case 45:
              this.list = tryList;
              break;
            case 46:
              this.list = goldList;
              break;
            case 47:
              this.list = plList;
              break;
            case 48:
              this.list = diamondList;
              break;
            default:
              this.list = tryList
          }
        }
      },
      toLevelUp(param) {
        if (!this.type) {
          return
        }
        this.$emit('levelUp', param)
      },
      exitOrg() {
        this.$emit('exitOrg')
      }
    }
  }
</script>

<style scoped>
  .container {
    position: relative;
    background: white;
  }

  .orgIcon {
    height: auto;
    width: 30px;
  }

  .titleBox {
    align-items: center;
    margin-bottom: 24px;
  }

  .title {

    font-family: PingFang-SC-Heavy;
    font-size: 20px;
    color: #323334;
    text-align: center;
    margin-left: 10px;
    margin-right: 10px;
    font-weight: bold;
  }

  .level {
    width: 295px;
    height: 48px;
    line-height: 48px;
    text-align: center;
    margin: 24px auto 0;
    background: #232322;
    border-radius: 24px;
    font-family: PingFang-SC-Bold;
    font-size: 16px;
    color: #FFFFFF;
  }

  .rightView {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
  }

  .itemView {
    box-sizing: border-box;
    width: 25%;
    height: 76px;
  }

  .rightView > :nth-child(3n+1), .rightView > :nth-child(3n+2) {
  }

  .container > p {
    text-align: center;
    font-size: 14px;
  }

  .bottomBox > p {
    text-align: center;
    font-size: 14px;
    color: #98999E;
    font-family: PingFang-SC-Medium;
  }
</style>
